package simtester.test.pages

import geb.Page

class RegisterPage extends Page {
    static url = 'user/register'
    static at = { $('title').text() == 'SimTester - Register User' }
    static content = {
        form { $('form') }
    }
    
    /**
     * Register a user, given username, password, and password_confirmation
     */
    void registerUser(args) {
        def user = args.username
        def pw = args.password ?: user
        def pw_conf = args.password_confirmation ?: pw ?: user

        form.with {
            username = user
            password = pw
            password_confirmation = pw_conf
            register().click([HomePage, RegisterPage])
        }
    }
}
